package com.thinkgem.jeesite.cn.yy.serviceimpl;

import com.thinkgem.jeesite.cn.yy.service.ProTableService;
import com.thinkgem.jeesite.cn.yy.utils.Paging;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by jws24 on 2017/11/22.
 */
@Service("ProTableService")
@Transactional
public class ProTableServiceImpl implements ProTableService {

    @Resource
     ProTableService proTableService;

    /**
     * 增加数据库表信息
     * @param tabName
     * @param proId
     * @param tabDescription
     */
    public void saveProTable(@Param("tab_name") String tabName, @Param("pro_id") int proId,
                             @Param("tab_description")String tabDescription) {
        proTableService.saveProTable(tabName, proId, tabDescription);
    }

    @Override
    public List<Map<String, String>> getProTableByName(@Param("pro_name") String proName, Paging paging) {
        return proTableService.getProTableByName(proName,paging);
    }

    /**
     * 根据项目名查表
     * @param proName
     * @return
     */


//    /**
//     * 全查数据库信息表
//     * @return
//     */
//    @Transactional(propagation= Propagation.NOT_SUPPORTED)
//    public List<Map<String,String>> getProTable(Paging paging) {
//        return proTableService.getProTable(paging);
//    }


    /**
     * 删除数据库表
     * @param tabId
     */


    public void delProTable(@Param("tab_id")int tabId) {
          proTableService.delProTable(tabId);
    }

    /**
     * 更改信息表
     * @param tabName
     */
    //
    @Transactional(propagation= Propagation.NOT_SUPPORTED)

    public void updateProTable(@Param("tab_id")int tabId,
                               @Param("tab_name") String tabName,
                               @Param("tab_description")String tabDescription)
    {
          proTableService.updateProTable(tabId,tabDescription,tabName);
   }

    /**
     * 通过表编号查表名
     * @param tabId
     * @return
     */
    public Map<String, String> getTableById(@Param("tab_id") int tabId) {
        return proTableService.getTableById(tabId);
    }

    /**
     * 清除表中内容
     */
    @Transactional(propagation= Propagation.NOT_SUPPORTED)
    public void truncateProTable(@Param("tab_id") int tabId) {
        proTableService.truncateProTable(tabId);
    }



    /**
     * 计算总页数
     * @return
     */
    @Transactional(propagation= Propagation.NOT_SUPPORTED)
    public int getProTablePage() {
        return proTableService.getProTablePage();
    }

    /**
     * 根据表编号查表
     * @param tabId
     * @return
     */



    /**
     * 增加根据项目名查表的操作
     * @param proName
     */
    @Transactional(propagation= Propagation.NOT_SUPPORTED)
    public void saveTableActionByProName(@Param("pro_name") String proName) {
          proTableService.saveTableActionByProName(proName);
    }

    /**
     * 根据项目编号查表
     */
    public int  selectId(@Param("pro_id") int proId, @Param("tab_name") String tabName) {
        return proTableService.selectId(proId,tabName);
    }


    public int byId(@Param("tab_id") int tabId, @Param("tab_name") String tabName) {
        return proTableService.byId(tabId,tabName);
    }

    /**
     * 增加删除表的操作
     * @param tabId
     */
    @Transactional(propagation= Propagation.NOT_SUPPORTED)
    public void saveDelTableAction(@Param("tab_id") int tabId) {
        proTableService.saveDelTableAction(tabId);
    }

    /**
     * 增加更改表的操作
     * @param tabId
     * @param tabName
     */
    @Transactional(propagation= Propagation.NOT_SUPPORTED)
    public void saveUpdateTableAction(@Param("tab_id") int tabId, @Param("tab_name") String tabName) {
        proTableService.saveUpdateTableAction(tabId,tabName);
    }
//
    /**
     * 增加增加数据表操作
     * @param proId
     */
    @Transactional(propagation= Propagation.NOT_SUPPORTED)
    public void saveSaveTableAction(@Param("pro_id") int  proId) {
        proTableService.saveSaveTableAction(proId);
    }


    public void saveGetProInfoByProName(@Param("pro_name") String proName) {

    }


}